//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_PARSERS_H
#define _UX_PARSERS_H

#include "IParser.h"
#include "../FileSys/CFileSystem.h"

namespace Engine
{
namespace Parsers
{

	//
	// OCF Parser
	//
	
	class _EXPORT_ OCFParser : public IParser
	{
	private:
		array<TFileAddress>		_aFiles;
		string_array_t			_aDirectories;
		
	private:
		bool _CompareFiles(IFilePtr pFile);
		bool _OpenFile(const char *pName, IFilePtr &pFile);
		bool _FindConst(const array<string> &aStr, CConfigBaseType *&pObj, config_const_node_t pNode, isize iBaseHeight);
		bool _Parse(IFilePtr pFile, config_node_t pNode, uint uSize = 0);
		
		static void _s_RecursiveSave(string &str, config_const_node_t pNode, int iHeight = 0);

	public:
		OCFParser();
		~OCFParser();

		bool  ParseFile(IFilePtr pFile, config_node_t pNode, uint uSize = 0);
		bool  Save(IFilePtr pFile, config_const_node_t pNode);
		void  SetDirectories(const string_array_t &aDir);
		bool  IsSupported(const char *pFileName);

		// CEngBaseObject //
		virtual void Release();
	};

//-------------------------------------------------------------------

}	// Parsers
}	// Engine

#endif	// _UX_PARSERS_H